package com.heima.comment.feign;

import com.heima.apis.comment.ICommentClient;
import com.heima.comment.service.CommentService;
import com.heima.mongo.comment.dtos.CommentDto;
import com.heima.mongo.comment.dtos.CommentLikeDto;
import com.heima.mongo.comment.dtos.CommentSaveDto;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class CommentClient implements ICommentClient {
    @Autowired
    private CommentService commentService;

    //保存评论
    @PostMapping("/api/v1/comment/save")
    public ResponseResult getSave(@RequestBody CommentSaveDto dto) {
        return commentService.getSave(dto);
    }

    //点赞
    @PostMapping("/api/v1/comment/like")
    public ResponseResult like(@RequestBody CommentLikeDto dto) {
        return commentService.like(dto);
    }

    //查询评论列表
    @PostMapping("/api/v1/comment/load")
    public ResponseResult load(@RequestBody CommentDto dto) {
        return commentService.load(dto);
    }
}
